home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 5.3 KB | 221 lines | [TEXT/CWIE] |
- // --------------------------------------------------------------------------------------
- // HackEvents.c
- //
- // Written by Don Arbow and Marc A. Raiser, EveryDay Objects, Inc.
- // in one day - June 26, 1997
- // --------------------------------------------------------------------------------------
-
- //#include "Subwoofer.h"
-
- #include "HackEvents.h"
- #include "HackWindows.h"
-
- extern Boolean done;
-
- static void DoCloseWindow(EventRecord *evt, WindowPtr theWindow);
- static void DoClickInContent(EventRecord *evt, WindowPtr theWindow);
- static void DoDragWindow(EventRecord *evt, WindowPtr theWindow);
- static void DoGrowWindow(EventRecord *evt, WindowPtr theWindow);
- static void DoZoom(EventRecord *evt, WindowPtr theWindow, short dir);
- static void DoMenu(long msel);
- static void DoKey(EventRecord *evt);
- static void DrawClippedGrowIcon(WindowPtr theWindow);
- static void DoUpdate(EventRecord *evt);
- static void ActivateWindow(WindowRef newFrontWindow);
- static void DeactivateWindow(WindowRef newBehindWindow);
- static void DoActivate(EventRecord *evt);
- static void DoMFinder(EventRecord *evt);
- static void DoClick(EventRecord *evt);
-
- //MW Added extern prototypes
- extern void MenuDispatch(short menuNumber,short itemNumber);
- extern void DrawImage(GrafPtr graf);
-
- static void DoCloseWindow(EventRecord *evt, WindowPtr theWindow)
- {
- if (TrackGoAway(theWindow,evt->where)) {
- CloseWindow(theWindow);
- }
- }
-
- static void DoClickInContent(EventRecord *evt, WindowPtr theWindow)
- {
- int part;
- ControlHandle ctlh;
- Point pt;
- GrafPtr saveport;
- Rect frame;
-
- if (theWindow!=FrontWindow()) {
- SelectWindow(theWindow);
- } else {
- GetPort(&saveport);
- SetPort(theWindow);
- pt = evt->where;
- GlobalToLocal(&pt);
- if (part = FindControl(pt,theWindow,&ctlh)) {
- /* TrackControl Goes Here */
- }
- SetPort(saveport);
- }
- }
-
- static void DoDragWindow(EventRecord *evt, WindowPtr theWindow)
- {
- //MW changed screenBits.bounds to qd.screenBits.bounds
- DragWindow(theWindow,evt->where,&qd.screenBits.bounds);
- }
-
- static void DoGrowWindow(EventRecord *evt, WindowPtr theWindow)
- {
- GrowHackWindow(evt, theWindow);
- }
-
- //MW added void return-types
- static void DoZoom(EventRecord *evt, WindowPtr theWindow, short dir)
- {
- if (TrackBox(theWindow, evt->where, dir)) {
- ZoomHackWindow(theWindow, dir);
- }
- }
-
- static void DoMenu(long msel)
- {
- int item,menu;
- item = LoWord(msel);
- menu = HiWord(msel);
- MenuDispatch(menu, item);
- HiliteMenu(0); /* remove menu title hiliting */
- }
-
- static void DoKey(EventRecord *evt)
- {
- char c;
-
- c = (char)evt->message & charCodeMask;
-
- if ((evt->modifiers & cmdKey) == false) {
- // KeyPressed = true;
- // KeyValue = c;
- } else {
- DoMenu(MenuKey(evt->message & charCodeMask));
- }
- }
-
- static void DrawClippedGrowIcon(WindowPtr theWindow)
- /*
- Clip out the lines that appear
- on the sides of a window with a grow icon.
- */
- {
- Rect clip;
- RgnHandle oldClip;
-
- oldClip = NewRgn();
- GetClip(oldClip);
- clip = theWindow->portRect;
- clip.left = clip.right - 15;
- clip.top = clip.bottom - 15;
-
- ClipRect(&clip);
-
- DrawGrowIcon(theWindow);
- SetClip(oldClip);
- }
-
- static void DoUpdate(EventRecord *evt)
- {
- WindowPtr updateWindow;
- GrafPtr savePort;
-
- GetPort(&savePort); /* save current port */
-
- updateWindow = (WindowPtr)evt->message; /* get windowPtr from event msg */
-
- UpdateHackWindow(updateWindow);
- }
-
-
- static void ActivateWindow(WindowRef newFrontWindow)
- {
- ActivateHackWindow(newFrontWindow);
- }
-
- static void DeactivateWindow(WindowRef newBehindWindow)
- {
- DeactivateHackWindow(newBehindWindow);
- }
-
- static void DoActivate(EventRecord *evt)
- {
- if (evt->modifiers & activeFlag)
- ActivateWindow((WindowRef)evt->message);
- else
- DeactivateWindow((WindowRef)evt->message);
- }
-
- static void DoMFinder(EventRecord *evt)
- {
- // if ((evt->message >> 24) == suspendResumeMessage)
- // BackgroundFlag = !(evt->message & resumeFlag);
- }
-
- static void DoClick(EventRecord *evt)
- {
- WindowPtr theWindow;
-
- switch (FindWindow(evt->where, &theWindow)) {
- case inDesk: break;
- case inMenuBar: DoMenu(MenuSelect(evt->where));
- break;
- case inSysWindow: SystemClick(evt,theWindow);
- break;
- case inContent: ClickHackWindow(evt,theWindow);
- break;
- case inDrag: DoDragWindow(evt,theWindow);
- break;
- case inGrow: DoGrowWindow(evt,theWindow);
- break;
- case inGoAway: DoCloseWindow(evt,theWindow);
- break;
- case inZoomIn: DoZoom(evt,theWindow,inZoomIn);
- break;
- case inZoomOut: DoZoom(evt,theWindow,inZoomOut);
- break;
- default: break;
- }
- }
-
- void EventLoop(void) {
-
- static EventRecord event;
- Boolean eventOccured;
-
- // KeyPressed = false; /* set to false every time through */
-
- eventOccured = WaitNextEvent(everyEvent,&event,10,nil);
-
- if (eventOccured) {
- switch (event.what) {
- case nullEvent: break;
- case mouseDown: DoClick(&event); break;
- case mouseUp: break;
- case keyDown: DoKey(&event); break;
- case keyUp: break;
- case autoKey: DoKey(&event); break;
- case updateEvt: DoUpdate(&event); break;
- case diskEvt: break;
- case activateEvt: DoActivate(&event); break;
- //case networkEvt: break;
- //case driverEvt: break;
- //case app1Evt: break;
- //case app2Evt: break;
- //case app3Evt: break;
- case osEvt: DoMFinder(&event); break;
- default: break;
- }
- }
- }
-
-
-